/*    */ package com.newcrm.businessarchives;
/*    */ 
/*    */ import com.newcrm.exception.CaptchaException;
/*    */ import com.newcrm.util.Util;
/*    */ import java.io.IOException;
/*    */ import java.io.UnsupportedEncodingException;
/*    */ import java.net.URLEncoder;
/*    */ import java.util.Date;
/*    */ import java.util.HashMap;
/*    */ import java.util.Map;
/*    */ import org.apache.log4j.Logger;
/*    */ import org.jsoup.Connection;
/*    */ import org.jsoup.Jsoup;
/*    */ import org.jsoup.nodes.Document;
/*    */ import org.jsoup.nodes.Element;
/*    */ import org.jsoup.select.Elements;
/*    */ 
/*    */ public class KunmingSearchEngine extends SearchEngine
/*    */ {
/* 26 */   private static Logger logger = Logger.getLogger(KunmingSearchEngine.class
/* 27 */     .getName());
/*    */ 
/* 29 */   private Map<String, String> params = new HashMap();
/*    */ 
/*    */   public KunmingSearchEngine(String name) {
/* 32 */     this.name = standardizedName(name);
/* 33 */     this.params.put("名称：", "CompanyName");
/* 34 */     this.params.put("类型：", "CompanyType");
/* 35 */     this.params.put("注册号（编号）：", "SN");
/* 36 */     this.params.put("注册资本（金）：", "RegisteredCapital");
/* 37 */     this.params.put("法定代表人/负责人/业主：", "Header");
/* 38 */     this.params.put("住所：", "Address");
/* 39 */     this.params.put("成立日期：", "FoundedDate");
/* 40 */     this.params.put("登记机关名称：", "RegistrationAuthority");
/* 41 */     this.params.put("经营范围：", "BusinessScope");
/*    */   }
/*    */ 
/*    */   protected Map<String, Object> getCompanyByWeb() throws CaptchaException
/*    */   {
/* 46 */     String url = null;
/*    */     try {
/* 48 */       url = "http://www.kmaic.gov.cn/KmaicOut/website/TbResult.aspx?zch=&gt=&qymc=" + URLEncoder.encode(this.name.trim(), "gb2312");
/*    */     } catch (UnsupportedEncodingException e) {
/* 50 */       url = "http://www.kmaic.gov.cn/KmaicOut/website/TbResult.aspx?zch=&gt=&qymc=" + this.name.trim();
/*    */     }
/*    */     try
/*    */     {
/* 54 */       Document doc = 
/* 55 */         Jsoup.connect(url)
/* 56 */         .userAgent("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.6; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET CLR 1.1.4322; .NET4.0C)")
/* 57 */         .referrer(
/* 58 */         "http://www.kmaic.gov.cn/KmaicOut/website/TbSearch.aspx")
/* 59 */         .timeout(10000).get();
/* 60 */       Elements links = doc.select("table tr td[align=right]");
/* 61 */       if ((links == null) || (links.size() == 0)) {
/* 62 */         return null;
/*    */       }
/* 64 */       Map info = new HashMap();
/* 65 */       for (Element item : links) {
/* 66 */         String key = item.text().trim();
/* 67 */         if (this.params.containsKey(key))
/*    */         {
/* 70 */           info.put((String)this.params.get(key), item.nextElementSibling().text());
/*    */         }
/*    */       }
/* 72 */       info.put("UpdateDate", Util.date2Str(new Date()));
/*    */ 
/* 75 */       saveDB(info);
/* 76 */       return info;
/*    */     } catch (IOException e) {
/* 78 */       logger.warn("get company from web failed", e);
/*    */     }
/*    */ 
/* 81 */     return null;
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.businessarchives.KunmingSearchEngine
 * JD-Core Version:    0.6.1
 */